"""
retrying模块使用示例
"""
import requests
from retrying import retry

baidu_url = 'https://www.baidu.com'

"""
错误重试3次，全部失败以后才算真正失败
"""


@retry(stop_max_attempt_number=3)
def parse_url(url):
    """
    :param url: url请求参数
    :return: 请求网站返回结果
    """
    response = requests.get(url, timeout=5)
    return response.text


"""
main主运行方法
"""
if __name__ == "__main__":
    content_text = parse_url(baidu_url)
    print(content_text)
